package main

import (
	"net"
	"fmt"
)

func main() {
	//１．确定本机ＩＰ和端口号
	service := ":54321"
	tcpaddr, _ := net.ResolveTCPAddr("tcp4", service)
	//2.监听
	listener, _ := net.ListenTCP("tcp", tcpaddr)
	//3.接收
	fmt.Println("服务器程序已经就绪，等待客户端的链接。。。")
	serverconn, _ := listener.Accept()
	//4.读数据
	bs := make([]byte, 512)
	n, _ := serverconn.Read(bs)
	fmt.Println(string(bs[:n]))
	a:=""
	fmt.Scanf("%s",&a)
	serverconn.Write([]byte(a))
	serverconn.Close()

}
